if __name__ == '__main__':  
    import socket  
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  
    sock.bind(('192.1.1.2', 1985))  
    sock.listen(5)  
    while True:  
        connection,address = sock.accept()  
        try:  
            connection.settimeout(5)  
            buf = connection.recv(1024)  
            if buf == 'change':
                shells="unlink /etc/sysconfig/network-scripts/ifcfg-eth0"
                os.system(shells)
                shells="cp /etc/sysconfig/network-scripts/eth0.bb  /etc/sysconfig/network-scripts/ifcfg-eth0"
                os.system(shells)
                shells="/etc/init.d/network restart"       
                os.system(shells)
                
                connection.send('yes') 
                
            elif buf == 'change2':
                shells="unlink /etc/sysconfig/network-scripts/ifcfg-eth0"
                os.system(shells)
                shells="cp /etc/sysconfig/network-scripts/eth0.salve  /etc/sysconfig/network-scripts/ifcfg-eth0"
                os.system(shells)
                shells="/etc/init.d/network restart"
                       
                os.system(shells)
                
                os.system('/usr/user_sh/tongbu.sh')
                connection.send('over')
                
            else:  
                connection.send('please go out!')  
        except socket.timeout:  
            print 'time out'  
        connection.close()  